import { visibleType } from '@/utils/basc-data'

export const summaryMap = new Map()
summaryMap.set('consumeCollect', (tds: any[]) => {
    //消费汇总列表 -- 超级管理员
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    const tds2: any = tds[2]
    // let tds3: any = tds[3]
    tds0.colSpan = 3
    tds1.style.display = 'none'
    tds2.style.display = 'none'
    // tds3.style.display = 'none'
})
summaryMap.set('consumeDetailed', (tds: any[]) => {
    //消费汇总弹窗列表
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    tds0.colSpan = 2
    tds1.style.display = 'none'
})
summaryMap.set('topUpCollectSuperAdmin', (tds: any[]) => {
    //充值汇总列表 -- 超级管理员
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    const tds2: any = tds[2]
    const tds3: any = tds[3]
    tds0.colSpan = 3
    tds1.style.display = 'none'
    tds2.style.display = 'none'
    // tds3.style.display = 'none'
})
summaryMap.set('topUpCollect', (tds: any[]) => {
    //充值汇总列表 -- 企业管理员
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    tds0.colSpan = 1
    // tds1.style.display = 'none'
})
summaryMap.set('topUpDetailed', (tds: any[]) => {
    //充值汇总弹窗列表
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    const tds2: any = tds[2]
    const tds3: any = tds[3]
    const tds4: any = tds[4]
    const tds5: any = tds[5]
    tds0.colSpan = 2
    tds1.style.display = 'none'
    tds2.colSpan = 4
    tds2.style.textAlign = 'center'
    tds3.style.display = 'none'
    tds4.style.display = 'none'
    tds5.style.display = 'none'
})
summaryMap.set('reconciliationCollectSuperAdmin', (tds: any[]) => {
    //对账汇总列表
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    const tds2: any = tds[2]
    const tds3: any = tds[3]
    const tds4: any = tds[4]
    tds0.colSpan = 3
    tds1.style.display = 'none'
    //tds2.style.display = 'none'
    //tds3.style.display = 'none'
    // tds4.style.display = 'none'
})
summaryMap.set('reconciliationDetailed', (tds: any[]) => {
    //对账汇总弹窗列表
    const tds0: any = tds[0]
    const tds1: any = tds[1]
    tds0.colSpan = 2
    tds1.style.display = 'none'
})

//条件
enum condition {
    a = '>',
    b = '>=',
    c = '==',
    d = '===',
    e = '<=',
    f = '<',
    g = '!==',
    h = '!='
}

export const setVisible = (item: visibleType | boolean, row: any) => {
    if (Object.prototype.toString.call(item) === '[object Boolean]') {
        return item
    } else {
        const obj: visibleType = item as visibleType

        if (obj.condition == condition.a) {
            //大于
            if (Number(row[obj.property]) > Number(obj.value)) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.b) {
            //大于等于
            if (Number(row[obj.property]) >= Number(obj.value)) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.c) {
            //等于
            if (row[obj.property] == obj.value) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.d) {
            //全等于
            if (row[obj.property] === obj.value) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.e) {
            //小于等于
            if (Number(row[obj.property]) <= Number(obj.value)) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.f) {
            //小于
            if (Number(row[obj.property]) < Number(obj.value)) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.g) {
            //不全等于
            if (row[obj.property] !== obj.value) {
                return true
            } else {
                return false
            }
        } else if (obj.condition == condition.h) {
            //不等于
            if (row[obj.property] != obj.value) {
                return true
            } else {
                return false
            }
        }
    }
}
